﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLVeChuyenBay
{
    public partial class frmManHinhChinh : Form
    {
        public frmManHinhChinh()
        {
            InitializeComponent();
        }
        private void frmManHinhChinh_Load(object sender, EventArgs e)
        {
            NgayHienTai.Text = "Hôm nay ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year;
            menuHeThong.Visible = true;
            menuQuanLy.Visible = true;
            menuNghiepVu.Visible = true;
            menuTroGiup.Visible = true;
        }
        public void HienThiForm(Form Frm)
        {

            if (frmManHinhChinh.ActiveForm.MdiChildren != null)
            {
                foreach (Form ChilForm in frmManHinhChinh.ActiveForm.MdiChildren)
                {
                    if (ChilForm.Name == Frm.Name)
                        ChilForm.Close();
                }
            }
            Frm.MdiParent = frmManHinhChinh.ActiveForm;
            Frm.Show();
        }
        #region Hệ Thống
        private void DangNhapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDangNhap frm = new frmDangNhap();
            HienThiForm(frm);
        }
        private void DoiMatKhauToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDoiMatKhau frm = new frmDoiMatKhau();
            HienThiForm(frm);
        }
        private void NguoiDungToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmNguoiDung frm = new frmNguoiDung();
            HienThiForm(frm);
        }
        private void ThoatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult hoi = MessageBox.Show("Bạn muốn thoát chương trình?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (hoi == DialogResult.Yes)
                Application.Exit();
        }
        
        #endregion
        #region Quản lý
        private void HanhKhachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmHanhKhach frm = new frmHanhKhach();
            HienThiForm(frm);
        }

        private void SanBayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSanBay frm = new frmSanBay();
            HienThiForm(frm);
        }

        private void TuyenBayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTuyenBay frm = new frmTuyenBay();
            HienThiForm(frm);
        }
        #endregion
        #region Nghiệp vụ
        private void TiepNhanChuyenBayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmLapLichCB frm = new frmLapLichCB();
            HienThiForm(frm);
        }

        private void TraCuuChuyenBayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmdanhsachCB frm = new frmdanhsachCB();
            HienThiForm(frm);
        }

        private void BanVeToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            frmVeChuyenBay frm = new frmVeChuyenBay();
            HienThiForm(frm);
        }

        private void DatVeToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            frmDatVe frm = new frmDatVe();
            HienThiForm(frm);
        }

        private void DoanhThuThangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDoanhThuThang frm = new frmDoanhThuThang();
            HienThiForm(frm);
        }
        private void DoanhThuNamToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmBaoCaoDoanhThuNam frm = new frmBaoCaoDoanhThuNam();
            HienThiForm(frm);
        }
        #endregion
        #region Trợ Giúp
        private void GioiThieuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmGioiThieu frm = new frmGioiThieu();
            HienThiForm(frm);
        }

        #endregion
        public void QuyenGiamDoc(bool key,bool login)
        {
            DangNhapToolStripMenuItem.Enabled = login;
            DangXuatToolStripMenuItem.Enabled = key;
            DoiMatKhauToolStripMenuItem.Enabled = key;
            NguoiDungToolStripMenuItem.Enabled = key;
            BaoCaoDoanhThuToolStripMenuItem.Enabled = key;
            QuyDinhToolStripMenuItem.Enabled = key;
        }
        public void QuyenNhanVien(bool key,bool login)
        {
            DangNhapToolStripMenuItem.Enabled = login;
            DangXuatToolStripMenuItem.Enabled = key;
            DoiMatKhauToolStripMenuItem.Enabled = key;
            HanhKhachToolStripMenuItem.Enabled = key;
            SanBayToolStripMenuItem.Enabled = key;
            TuyenBayToolStripMenuItem.Enabled = key;
            HangVeToolStripMenuItem.Enabled = key;
            TiepNhanChuyenBayToolStripMenuItem.Enabled = key;
            DatVeToolStripMenuItem.Enabled = key;
            BanVeToolStripMenuItem.Enabled = key;
        }

        private void DangXuatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DangNhapToolStripMenuItem.Enabled = true;
            DangXuatToolStripMenuItem.Enabled = false;
            DoiMatKhauToolStripMenuItem.Enabled = false;
            HanhKhachToolStripMenuItem.Enabled = false;
            SanBayToolStripMenuItem.Enabled = false;
            TuyenBayToolStripMenuItem.Enabled = false;
            HangVeToolStripMenuItem.Enabled = false;
            TiepNhanChuyenBayToolStripMenuItem.Enabled = false;
            DatVeToolStripMenuItem.Enabled = false;
            BanVeToolStripMenuItem.Enabled = false;
            NguoiDungToolStripMenuItem.Enabled = false;
            BaoCaoDoanhThuToolStripMenuItem.Enabled = false;
            QuyDinhToolStripMenuItem.Enabled = false;
        }

        
        
        
        
    }
}
